/**
 *  Document   : Room
 *  Created on : 17 juil. 2008, 10:21:41
 *  Author     : Rivo
 */

package gla.centralhotel.model;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;


@Entity
@Table(name = "room")
@NamedQueries({@NamedQuery(name = "Room.findById", query = "SELECT r FROM Room r WHERE r.id = :id"),
@NamedQuery(name = "Room.findByNumber", query = "SELECT r FROM Room r WHERE r.number = :number")})
public class Room implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Column(name = "id", nullable = false)
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    private Integer id;
    @Column(name = "number")
    private String number;
//    @OneToMany(cascade = CascadeType.ALL, mappedBy = "refRoom")
//    private Collection<Price> priceCollection;    
//    @OneToMany(cascade = CascadeType.ALL, mappedBy = "refRoom")
//    private Collection<RoomBookingHasRoom> roomBookingHasRoomCollection;
    @JoinColumn(name = "ref_hotel", referencedColumnName = "id")
    @ManyToOne
    private Hotel refHotel;
    /**
     * Information sur le nom de l'hotel concerné
     */
    @Transient
    private String hotelName;
    @JoinColumn(name = "ref_room_type", referencedColumnName = "id")
    @ManyToOne
    private RoomType refRoomType;
    /**
     * Information sur le type de chambre concerné
     */
    @Transient
    private String roomType;
    
    public Room() {
    }

    public Room(Integer id) {
        this.id = id;
    }

    public String getHotelName()
    {
        return hotelName;
    }

    public void setHotelName(String hotelName)
    {
        this.hotelName = hotelName;
    }

    public String getRoomType()
    {
        return roomType;
    }

    public void setRoomType(String roomType)
    {
        this.roomType = roomType;
    }
    
    

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getNumber() {
        return number;
    }

    public void setNumber(String number) {
        this.number = number;
    }

//    public Collection<Price> getPriceCollection() {
//        return priceCollection;
//    }
//
//    public void setPriceCollection(Collection<Price> priceCollection) {
//        this.priceCollection = priceCollection;
//    }
//
//    public Collection<RoomBookingHasRoom> getRoomBookingHasRoomCollection() {
//        return roomBookingHasRoomCollection;
//    }
//
//    public void setRoomBookingHasRoomCollection(Collection<RoomBookingHasRoom> roomBookingHasRoomCollection) {
//        this.roomBookingHasRoomCollection = roomBookingHasRoomCollection;
//    }

    public Hotel getRefHotel() {
        return refHotel;
    }

    public void setRefHotel(Hotel refHotel) {
        this.refHotel = refHotel;
    }

    public RoomType getRefRoomType() {
        return refRoomType;
    }

    public void setRefRoomType(RoomType refRoomType) {
        this.refRoomType = refRoomType;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Room)) {
            return false;
        }
        Room other = (Room) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "gla.centralhotel.model.Room[id=" + id + "]";
    }

}
